/*
 *  $Id: StunningStare.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Air.Spells {
    public class StunningStare: TargetEnchantmentCard<Creature> {
        public StunningStare(): base("001_a_s_stunning_stare") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Air;
            Value = 100;
            Target = CreatureTarget.Enemy;
            AddManaCost(ElementType.Air, 2);
        }

        protected override void DoAction(TargetArgs<Creature> args) {
            args.Target.State = CreatureState.Tapped;
            base.DoAction(args);
        }
        protected override EnchantmentAffect CreateEnchantment() {
            return new StunningStareAffect();
        }

        private class StunningStareAffect: EnchantmentAffect<StunningStare> {
            public StunningStareAffect() {
                Add(new Affects.Idler());
                Add(new Affects.AbilityAffect(new StunningStareRestore(this)));
            }
        }

        private class StunningStareRestore: AbilityCard {
            private StunningStareAffect _affect;

            public StunningStareRestore(): base("001_a_a_stunning_stare_restore") {
                Level = CompleteLevel.ReadyForTest;
                SetPictureSource<StunningStare>();
                Element = ElementType.Air;
                AllowInTapped = true;
                TapCreatureAfterUse = false;
            }
            public StunningStareRestore(StunningStareAffect affect): this() {
                _affect = affect;
            }

            public override void DoAction(TargetArgs args) {
                Creature cr = args.Caster as Creature;
                if (cr == null) return;
                if (_affect == null) return;
                cr.RemoveAffect(_affect);
                cr.DamageBy(NewDamage(args, 2));
                cr.State = CreatureState.Untapped;
            }
        }
    }
}
